package jbstoremgmt.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jbstoremgmt.service.LoginFormBean;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.validation.BindException;


public class LoginSuccessController extends SimpleFormController{

	
	public Object formBackingObject(HttpServletRequest request) throws ServletException
	{
		LoginFormBean backingObject = new LoginFormBean();
		return backingObject;
	}
	
	/*public ModelAndView handleRequest(HttpServletRequest request,HttpServletResponse response) throws Exception
	{
		System.out.println("inside handleRequest");
		if(null !=request.getSession(false))
		{
			return new ModelAndView("loginsuccess");
		}
		HttpSession jbSession = request.getSession(true);
		System.out.println("New Session Created : "+ jbSession);
		return new ModelAndView("loginform");
	}*/
	
	/*public void doSubmitAction(Object command)
	{
		
		LoginFormBean  lBean = (LoginFormBean)command;
		System.out.println("username :"+lBean.getUsrid());
		System.out.println("password :"+lBean.getUsrpwd());
		
	}*/

	/* The below method can be used if we need to move to another page rather than the one
	 * defined in the successView property page.  
	 */
 
	public ModelAndView onSubmit(HttpServletRequest request,HttpServletResponse response, Object command,BindException errors) throws ServletException , Exception
	{
		LoginFormBean  lBean = (LoginFormBean)command;
		System.out.println("username :"+lBean.getUsrid());
		System.out.println("password :"+lBean.getUsrpwd());
				
		//Create session now.


		
		return new ModelAndView("loginsuccess");
	}
		
}




























